home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / DEV / I-Z / MacRecorder® HackersToolkit.cpt / DialogUtils.c < prev    next >
Text File  |  1989-12-07  |  2KB  |  91 lines

  1. /*
  2.       General functions for manipulating Dialogs
  3.         Copyright © 1989  Farallon Computing, Inc
  4. */
  5.  
  6. void    SetRadioButton( DialogPtr, short);
  7. void    ToggleRadioButtons( DialogPtr, short, short);
  8. void    OutlineDefaultButton( DialogPtr);
  9. void    HiliteDialogItem( DialogPtr, short);
  10. void    UnHiliteDialogItem( DialogPtr, short);
  11.  
  12. /*
  13. **    Outline dialog's default button as per
  14. **    Inside Mac Vol.I page 413
  15. */
  16. void    OutlineDefaultButton(    theDialog)
  17.     DialogPtr        theDialog;
  18. {
  19.     GrafPtr        savePort;
  20.     Rect        box;
  21.     short        itemType;
  22.     Handle        item;
  23.     
  24.     GetPort( &savePort);
  25.     SetPort( theDialog);
  26.     
  27.     GetDItem( theDialog, 1, &itemType, &item, &box);
  28.     PenSize(3,3);
  29.     InsetRect( &box, -4, -4);
  30.     FrameRoundRect( &box, 16, 16);
  31.     
  32.     SetPort( savePort);
  33. }
  34.  
  35. /* place a bullet in the indicated radio button */
  36. void    SetRadioButton( theDialog, theItem)
  37.     DialogPtr    theDialog;
  38.     short        theItem;
  39. {
  40.     ControlHandle    control;
  41.     short            itemType;
  42.     Rect            box;
  43.     
  44.     GetDItem(    theDialog, theItem, &itemType, &control, &box);
  45.     SetCtlValue( control, 1);
  46. }
  47.  
  48. /*
  49. **    take bullet out of oldItem
  50. **    stick bullet in newItem
  51. */    
  52. void    ToggleRadioButtons( theDialog, oldItem, newItem)
  53.     DialogPtr    theDialog;
  54.     short        oldItem;
  55.     short        newItem;
  56. {
  57.     ControlHandle    control;
  58.     short            itemType;
  59.     Rect            box;
  60.     
  61.     GetDItem(    theDialog, oldItem,  &itemType, &control, &box);
  62.     SetCtlValue( control, 0);
  63.     GetDItem(    theDialog, newItem, &itemType, &control, &box);
  64.     SetCtlValue( control, 1);
  65. }
  66.  
  67. void    HiliteDialogItem( theDialog, itemNo)
  68.     DialogPtr    theDialog;
  69.     short        itemNo;
  70. {
  71.     ControlHandle    control;
  72.     short            itemType;
  73.     Rect            box;
  74.  
  75.     GetDItem(    theDialog, itemNo,  &itemType, &control, &box);
  76.     HiliteControl( control, 0);     /* Hilite Item */ 
  77. }
  78.  
  79. void    UnHiliteDialogItem( theDialog, itemNo)
  80.     DialogPtr    theDialog;
  81.     short        itemNo;
  82. {
  83.     ControlHandle    control;
  84.     short            itemType;
  85.     Rect            box;
  86.     
  87.     GetDItem(    theDialog, itemNo,  &itemType, &control, &box);
  88.     HiliteControl( control, 255);     /* UnHilite Item */ 
  89. }
  90.  
  91.